﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for GroupNewsDAL
/// </summary>
public class GroupNewsDAL : BaseDAL
{
    public DataSet List()
    {
        DataSet ds = new DataSet();

        string query = "select * from GroupNews";
        ds = base.RunQuery(query);
        return ds;
    }
    public DataSet Detail(int groupNewsId)
    {
        DataSet ds = new DataSet();

        string query = "select * from GroupNews where Id = " + groupNewsId.ToString();
        ds = base.RunQuery(query);

        return ds;
    }
    public DataSet UpdateStatusActive(int groupNewsId, int Status)
    {
        DataSet ds = new DataSet();
        string query = string.Format("Update GroupNews set Status={0} where id={1}; select {1} as Id", Status, groupNewsId);
        ds = base.RunQuery(query);
        return ds;
    }
    public DataSet Update(int groupNewsId, string name, int Status)
    {
        DataSet ds = new DataSet();

        string query = string.Format("Update GroupNews set Name='{0}', Status={1} where Id={2}; Select {2} as Id;", name, Status, groupNewsId.ToString());
        ds = base.RunQuery(query);

        return ds;
    }
    public DataSet Insert(string name, int Status)
    {
        DataSet ds = new DataSet();

        string query = string.Format("insert into GroupNews (Name, Status) values ('{0}', '{1}'); Select @@identity as Id;", name, Status);
        ds = base.RunQuery(query);

        return ds;
    }
}